package com.shiwaixiangcun.customer.adapter;

import android.widget.ImageView;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.SectionEntity;
import com.shiwaixiangcun.customer.R;
import com.shiwaixiangcun.customer.entity.MyTicketInfo;
import com.shiwaixiangcun.customer.utils.DateUtil;

import java.util.List;

/**
 * Author   Administrator
 * Date     2017/12/13
 * Desc     我的车票Adapter
 *
 * @author Administrator
 */

public class AdapterMyTicket extends BaseSectionQuickAdapter<AdapterMyTicket.MyTicketSection, BaseViewHolder> {


    public AdapterMyTicket(List<MyTicketSection> data) {
        super(R.layout.item_mylayout_ticket, R.layout.item_layout_myticket_header, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyTicketSection item) {

        MyTicketInfo dataBean = item.dataBean;
        ImageView ivFlag = helper.getView(R.id.iv_stature);
        helper.setText(R.id.tv_start_time, DateUtil.INSTANCE.getTimeFormatString(dataBean.getRideTime()));
        helper.setText(R.id.tv_start, dataBean.getStartSite());
        helper.setText(R.id.tv_end, dataBean.getEndSite());
        switch (dataBean.getStatus()) {
            case "Wait_Check":
                ivFlag.setImageResource(R.drawable.flag_unuse);
                break;
            case "Checked":
                ivFlag.setImageResource(R.drawable.flag_used);
                break;
            default:
                ivFlag.setImageResource(R.drawable.flag_returned);

                break;
        }
    }


    public void addData(List<AdapterMyTicket.MyTicketSection> data) {
        this.mData.addAll(data);
        notifyDataSetChanged();
    }

    @Override
    protected void convertHead(BaseViewHolder helper, MyTicketSection item) {
        if (item.isHeader) {
        }

    }

    public static final class MyTicketSection extends SectionEntity<MyTicketInfo> {

        private String strHeader;
        private MyTicketInfo dataBean;

        public MyTicketSection(boolean isHeader, String header) {
            super(isHeader, header);
            this.isHeader = true;
            strHeader = header;

        }

        public MyTicketSection(MyTicketInfo midwayLine) {
            super(midwayLine);
            this.dataBean = midwayLine;
        }
    }
}
